package com.oocl.admin_platform.util;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Random;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;

public class CodeUtil {

	public static String GeneratCode(BufferedImage bi){
		StringBuffer code = new StringBuffer();
		Graphics graphics = bi.getGraphics();
		graphics.setColor(new Color(0,255,255));
		graphics.fillRect(0, 0, 100, 30);
		Random randon = new Random();
		for(int i=0;i<4;i++){
			int index = randon.nextInt(9);
			graphics.setColor(new Color(255, 0, 0));
			graphics.drawString(index+"", 5+(i*20), 15);
			code.append(index);
		}
		
		return code.toString();
	}
}
